﻿$(function() {
	//添加图片移入时插入事件
	$("#commBox li a img").live("mouseenter",showBigPic);
	//添加小图 移入 移出 点击事件
	$("#commBox li a").live({
		"mouseenter":goToBig,
		"mouseleave":goToSmall,
		"click":showSmallWin
	})

});

//插入大图
function showBigPic(){
	var obj = $(this);
	var src = "";
	var img;
	if(obj.parent().find("img").length != 2){
		src = obj.attr("src");
		src = src.replace(/\.jpg/,"_big.jpg")
		img = $("<img src="+src+" onerror='this.src=\"images/blank.gif\"' />");
		obj.before(img)
	}
}
//鼠标经过变大
function goToBig(){
	var obj = $(this);
	obj.parent().css({"z-index":200});
	obj.find("img:last").stop().animate({
		opacity:0
	},300)
	obj.stop().animate({
		width:105,
		height:105,
		top:-20,
		left:-20
	},300,"jswing")
}
//鼠标经过变小
function goToSmall(){
	var obj = $(this);
	obj.parent().css({"z-index":120});
	obj.find("img:last").stop().animate({
		opacity:1
	},300)
	obj.stop().animate({
		width:65,
		height:65,
		top:0,
		left:0
	},300,"jswing",function(){
		obj.parent().css({"z-index":100});
	})
}
//鼠标点击打开新窗口
function showSmallWin(){
	var $obj = $(this);
	var dataid = $obj.attr("dataid");
	var href = "images/bigPic/dataid_" + dataid + "/picshow.html";
	var height = $obj.attr("wHeight") || "800";
	var width = $obj.attr("wWidth") || "1280";
	window.open(href,'','height='+height+',width='+width+',top=300,left=300,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no');
	return false;
}









